package practite.sort;

import java.util.Arrays;
import java.util.Random;

public class ChooseSort {
    public static void main(String[] args) {
        int[] array = getRandomArray();
        System.out.println(Arrays.toString(array));
        int maxmax = 0;
        int max = 0;
        for (int i = 0; i < array.length-1; i++) {
            max = i;
            for (int j = i; j < array.length; j++) {
                if (array[max]<array[j]){
                    max = j;
                }
            }
            if (array[i]<array[max]) {
                maxmax = array[max];
                array[max] = array[i];
                array[i] = maxmax;
                System.out.println(Arrays.toString(array));
            }
        }
        System.out.println(Arrays.toString(array));


    }
    //生成随机数
    public static int getRandom(){
        Random random = new Random();
        int a = random.nextInt(100)+1;
        return a;
    }

    //生成随机数的十位数组
    public static int[] getRandomArray(){
        int[] a = new int[10];
        for (int i = 0; i < a.length; i++) {
            a[i] = getRandom();

        }
        return a;
    }
}
